package com.itheima.config;



import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringBootdxlConfig {


    //声明交换机
    @Bean("test_topic_exchange")
    public Exchange getExchang(){
        return ExchangeBuilder.topicExchange("test_topic_exchange").build();
    }

    //声明队列
    @Bean("test_queue")
    public Queue getQueue(){
        Queue test_queue = QueueBuilder.durable("test_queue").
                withArgument("x-dead-letter-exchange","test_topic_exchangeDXL").
                withArgument("x-dead-letter-routing-key","#").
                build();
        return test_queue;
    }

     @Bean
     public Binding bindingQueueExchane(@Qualifier("test_topic_exchange") Exchange exchange, @Qualifier("test_queue") Queue queue){

        return BindingBuilder.bind(queue).to(exchange).with("#").noargs();
     }


     @Bean("test_topic_exchangeDXL")
     public Exchange getExhangeDLX(){
        return ExchangeBuilder.topicExchange("test_topic_exchangeDXL").build();
     }


     @Bean("test_queueDXL")
     public Queue getQueueDXL(){
        return QueueBuilder.durable("test_queueDXL").build();
     }

     @Bean
     public Binding bindingQueueExchaneQXL(@Qualifier("test_topic_exchangeDXL") Exchange exchange, @Qualifier("test_queueDXL") Queue queue){
        return  BindingBuilder.bind(queue).to(exchange).with("#").noargs();
     }




}
